/*

 * Licensed to the Apache Software Foundation (ASF) under one

 * or more contributor license agreements.  See the NOTICE file

 * distributed with this work for additional information

 * regarding copyright ownership.  The ASF licenses this file

 * to you under the Apache License, Version 2.0 (the

 * "License"); you may not use this file except in compliance

 * with the License.  You may obtain a copy of the License at

 *

 *     http://www.apache.org/licenses/LICENSE-2.0

 *

 * Unless required by applicable law or agreed to in writing, software

 * distributed under the License is distributed on an "AS IS" BASIS,

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

 * See the License for the specific language governing permissions and

 * limitations under the License.

 */

package com.bff.gaia.unified.sdk.transforms.xjoin.core.side;

/*

 * Licensed to the Apache Software Foundation (ASF) under one or more

 * contributor license agreements.  See the NOTICE file distributed with

 * this work for additional information regarding copyright ownership.

 * The ASF licenses this file to You under the Apache License, Version 2.0

 * (the "License"); you may not use this file except in compliance with

 * the License.  You may obtain a copy of the License at

 *

 *    http://www.apache.org/licenses/LICENSE-2.0

 *

 * Unless required by applicable law or agreed to in writing, software

 * distributed under the License is distributed on an "AS IS" BASIS,

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

 * See the License for the specific language governing permissions and

 * limitations under the License.

 */



import com.google.common.base.Strings;

import java.io.Serializable;

import com.bff.gaia.unified.sdk.transforms.xjoin.core.enums.EJoinType;



/** Description: gaia-parent Created by tiger on 2019/7/18 17:16. */

public class JoinInfo implements Serializable {

  private static final long serialVersionUID = -1L;



  // 左表是否是维表

  private boolean leftIsSideTable;



  // 右表是否是维表

  private boolean rightIsSideTable;



  private String leftTableName;



  private String leftTableAlias;



  private String rightTableName;



  private String rightTableAlias;



  private EJoinType joinType;



  public String getSideTableName() {

    if (leftIsSideTable) {

      return leftTableAlias;

    }



    return rightTableAlias;

  }



  public String getNonSideTable() {

    if (leftIsSideTable) {

      return rightTableAlias;

    }



    return leftTableAlias;

  }



  public String getNewTableName() {

    // 兼容左边表是as 的情况

    String leftStr = leftTableName;

    leftStr = Strings.isNullOrEmpty(leftStr) ? leftTableAlias : leftStr;

    return leftStr + "_" + rightTableName;

  }



  public String getNewTableAlias() {

    return leftTableAlias + "_" + rightTableAlias;

  }



  public boolean isLeftIsSideTable() {

    return leftIsSideTable;

  }



  public void setLeftIsSideTable(boolean leftIsSideTable) {

    this.leftIsSideTable = leftIsSideTable;

  }



  public boolean isRightIsSideTable() {

    return rightIsSideTable;

  }



  public void setRightIsSideTable(boolean rightIsSideTable) {

    this.rightIsSideTable = rightIsSideTable;

  }



  public String getLeftTableName() {

    return leftTableName;

  }



  public void setLeftTableName(String leftTableName) {

    this.leftTableName = leftTableName;

  }



  public String getRightTableName() {

    return rightTableName;

  }



  public void setRightTableName(String rightTableName) {

    this.rightTableName = rightTableName;

  }



  public boolean checkIsSide() {

    return isLeftIsSideTable() || isRightIsSideTable();

  }



  public String getLeftTableAlias() {

    return leftTableAlias;

  }



  public void setLeftTableAlias(String leftTableAlias) {

    this.leftTableAlias = leftTableAlias;

  }



  public String getRightTableAlias() {

    return rightTableAlias;

  }



  public void setRightTableAlias(String rightTableAlias) {

    this.rightTableAlias = rightTableAlias;

  }



  public EJoinType getJoinType() {

    return joinType;

  }



  public void setJoinType(EJoinType joinType) {

    this.joinType = joinType;

  }

}